package cn.ctodb.cms.domain;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.springframework.data.elasticsearch.annotations.Document;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Objects;

/**
 * A CmsModel.
 */
@Entity
@Table(name = "cms_model")
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
@Document(indexName = "cmsmodel")
public class CmsModel implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    private Long id;

    @Column(name = "name")
    private String name;

    @Column(name = "path")
    private String path;

    @Column(name = "tpl_channel_prefix")
    private String tplChannelPrefix;

    @Column(name = "tpl_content_prefix")
    private String tplContentPrefix;

    @Column(name = "sort")
    private Integer sort;

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public CmsModel name(String name) {
        this.name = name;
        return this;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getPath() {
        return path;
    }

    public CmsModel path(String path) {
        this.path = path;
        return this;
    }

    public void setPath(String path) {
        this.path = path;
    }

    public String getTplChannelPrefix() {
        return tplChannelPrefix;
    }

    public CmsModel tplChannelPrefix(String tplChannelPrefix) {
        this.tplChannelPrefix = tplChannelPrefix;
        return this;
    }

    public void setTplChannelPrefix(String tplChannelPrefix) {
        this.tplChannelPrefix = tplChannelPrefix;
    }

    public String getTplContentPrefix() {
        return tplContentPrefix;
    }

    public CmsModel tplContentPrefix(String tplContentPrefix) {
        this.tplContentPrefix = tplContentPrefix;
        return this;
    }

    public void setTplContentPrefix(String tplContentPrefix) {
        this.tplContentPrefix = tplContentPrefix;
    }

    public Integer getSort() {
        return sort;
    }

    public CmsModel sort(Integer sort) {
        this.sort = sort;
        return this;
    }

    public void setSort(Integer sort) {
        this.sort = sort;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (o == null || getClass() != o.getClass()) {
            return false;
        }
        CmsModel cmsModel = (CmsModel) o;
        if (cmsModel.id == null || id == null) {
            return false;
        }
        return Objects.equals(id, cmsModel.id);
    }

    @Override
    public int hashCode() {
        return Objects.hashCode(id);
    }

    @Override
    public String toString() {
        return "CmsModel{" +
            "id=" + id +
            ", name='" + name + "'" +
            ", path='" + path + "'" +
            ", tplChannelPrefix='" + tplChannelPrefix + "'" +
            ", tplContentPrefix='" + tplContentPrefix + "'" +
            ", sort='" + sort + "'" +
            '}';
    }
}
